import static org.junit.Assert.*;
import org.junit.Test;
import java.io.*;
import java.util.ArrayList;

import probe.logic.*;

public class testXML {

	private static final String testXMLName = "test.xml";

	public ArrayList<String> convertToListOfStrings(ArrayList<Task> listTask) {

		ArrayList<String> listString = new ArrayList<String>();
		for (int i = 0; i < listTask.size(); i++) {
			Task task = listTask.get(i);
			String taskString = task.taskName + task.deadline + task.time
					+ task.startingDate + task.endingDate + task.startingTime
					+ task.endingTime + task.taskStatus;
			listString.add(taskString);
		}
		
		return listString;
	}

	@Test
	public void testImportXML() throws IOException {
		
		BufferedWriter writer = new BufferedWriter(new FileWriter(testXMLName));
		writer.write("<task>\n");
		writer.write("<name>watch movie</name>\n");
		writer.write("<status>DONE</status>\n");
		writer.write("<date>13/10/12</date>");
		writer.write("<time>1530</time>");
		writer.write("<\task>\n");
		writer.close();
		
		ArrayList<Task> listTask= XML.getListOfTasksFromXml();
		ArrayList<Task> expected = new ArrayList<Task>();
		expected.add(new Task("watch movie",new Date("13/10/12"),new Time("1530"),Task.TaskStatus.DONE));

		assertEquals(convertToListOfStrings(listTask),convertToListOfStrings(expected));
	}
}